package com.midian.service.pic.impl;

import java.io.Serializable;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.midian.common.dao.BaseDaoTemplet;
import com.midian.common.dao.OrderHelper;
import com.midian.common.dao.SearchHelper;
import com.midian.common.exception.BizException;
import com.midian.common.pager.Pager;
import com.midian.common.utils.PicUtils;
import com.midian.model.pic.Pic;
import com.midian.service.common.BaseService;
import com.midian.service.pic.IPicService;

/**
 * 图片业务实现类
 * @author Mengfh
 *
 */
@Service("picService")
public class PicServiceImpl extends BaseService implements IPicService {
	
	/**图片DAO*/
	private BaseDaoTemplet<Pic> picDAO;
	private PicUtils picUtils;
	
	@Resource(name="picUtils")
	public void setPicUtils(PicUtils picUtils) {
		this.picUtils = picUtils;
	}
	@Resource(name = "picDAO")
	public void setPicDAO(BaseDaoTemplet<Pic> picDAO) {
		this.picDAO = picDAO;
	}

	@Override
	public Pic add(Pic target) throws BizException {
		this.picDAO.add(target);
		return target;
	}

	@Override
	public void update(Pic target) throws BizException {
		this.picDAO.update(target);
	}

	@Override
	public void delete(Serializable id) throws BizException {
		this.picDAO.delete(id);
	}

	@Override
	public void delete(Serializable[] ids) throws BizException {
		this.picDAO.delete(ids);
	}

	@Override
	public Pic get(Serializable id) throws BizException {
		return this.picDAO.get(id);
	}

	@Override
	public List<Pic> showList(Pic target, Pager pager, List<OrderHelper> helper)
			throws BizException {
		return this.picDAO.find(target, getSearchHelper(), helper, pager);
	}

	@Override
	public void opDelFlag(Serializable[] ids, Integer status) throws BizException {
		
	}

	@Override
	protected List<SearchHelper> getSearchHelper() {
		return null;
	}
	@Override
	public void updatePicSuffix(String suffix, String picId) {
		StringBuilder sb= new StringBuilder("update Pic o set o.picSuffix=? where o.id=?");
		this.picDAO.update(sb.toString(), new Object[]{suffix,picId});
		
	}
	
}
